﻿using System;
using System.Windows.Forms;
using Rerun.Exceptions;

namespace Rerun.Services {

    /// <summary>
    /// 
    /// </summary>
    public class UserNotificationService {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        /// <param name="caption"></param>
        /// <exception cref="NotificationException"></exception>
        public static void ShowSimpleNotification(string message, string caption) {
            try {
                ShowNotification(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            } catch(NotificationException ne) {
                throw new NotificationException(ne.Message);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        /// <param name="caption"></param>
        /// <exception cref="NotificationException"></exception>
        public static void ShowSimpleQuestion(string message, string caption) {
            try {
                ShowNotification(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Question);
            } catch(NotificationException ne) {
                throw new NotificationException(ne.Message);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        /// <param name="caption"></param>
        /// <param name="messageBoxButtons"></param>
        /// <param name="messageBoxIcon"></param>
        /// <exception cref="NotificationException"></exception>
        private static void ShowNotification(string message, string caption, MessageBoxButtons messageBoxButtons, MessageBoxIcon messageBoxIcon) {
            try {
                MessageBox.Show(message, caption, messageBoxButtons, messageBoxIcon);
            } catch(Exception e) {
                throw new NotificationException(string.Format("There was a problem trying to show a user notification: {0}", e.Message));
            }
        }
    }
}